<!DOCTYPE html>
<html>
{include file="public/header" /}
<body>
<div class="layui-fluid" id="app">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <!--<div class="layui-card-header">财务报表,提现管理</div>-->
                <div class="layui-card-body">
                    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                        <ul class="layui-tab-title">
                            <li class="layui-this">信息管理</li>
                            <!--<li onclick="go('add_cases')">新增案例</li>-->
                        </ul>
                        <div class="layui-tab-content" style="padding-left: 0px;padding-right: 0px">

                            <div class="layui-tab-item layui-show">

                                <div>
                                    <div class="layui-btn-group">
                                        <!--<button class="layui-btn ">推荐</button>-->
                                        <button class="layui-btn " onclick="del2();">批量删除</button>
                                        <!--<button class="layui-btn" >批量操作1</button>-->
                                    </div>

                                    <div class="layui-inline" style="float: right">
                                        <form class="layui-form" action="">
                                            <div class="layui-form-item" style="margin-bottom: 0px">

                                                <div class="layui-inline" style="margin-right: 0px">
                                                    <!--<label class="layui-form-label">密码</label>-->
                                                    <div class="layui-input-inline" style="width: 200px;">
                                                        <input type="text" name="keyword" autocomplete="off"
                                                               placeholder="请输入路线"
                                                               class="layui-input">
                                                    </div>
                                                </div>

                                                <div class="layui-inline" style="margin-right: 0px">

                                                    <div class="layui-btn-group layui-inline" style="margin: 0px">
                                                        <!--此重置 仅仅是个跳转链接-->
                                                        <button  onclick="go('index')" class="layui-btn layui-btn-primary">重置</button>
                                                        <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">
                                                            <i class="layui-icon">&#xe615;</i>查找
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>

                                <div class="layadmin-trailer ">
                                    <table class="layui-table" lay-skin="line">
                                        <thead>
                                        <tr>
                                            <th style="width: 5%;"></th>
                                            <!--<th>#ID</th>-->
                                            <th>路线</th>
                                            <th>起始位置</th>
                                            <th>终点位置</th>
                                            <th>联系方式</th>
                                            <th>出发时间</th>
                                            <th>发布时间</th>
                                            <th>类型</th>
                                            <th>状态</th>

                                            <th style="width: 150px"></th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr v-for="(item,index) in items" :data_id="item.id">
                                            <td style="width: 20px;text-align: center">
                                                <input type="checkbox" class="vue_index" name="id" :value="item.id"
                                                       style="zoom: 150%">
                                            </td>
                                            <!--<td>{{item.id}}</td>-->
                                            <td>{{item.content}}</td>
                                            <td>{{item.begin_place}}</td>
                                            <td>{{item.end_place}}</td>
                                            <td>{{item.phone}}</td>
                                            <td>{{item.depart_time}}</td>
                                            <td>{{item.create_time}}</td>

                                            <td  v-if="item.type == 1">乘车</td>
                                            <td  v-if="item.type == 2">载客</td>
                                            <!--<td>{{item.status}}</td>-->
                                            <td  v-if="item.status == -1">过期</td>
                                            <td  v-if="item.status == 0">发布中</td>
                                            <td  v-if="item.status == 1">行驶中</td>
                                            <td  v-if="item.status == 2">已完成</td>



                                            <td style="text-align: center">

                                                <div class="layui-btn-group">
                                                    <a class="layui-btn layui-btn-sm layui-btn-primary"
                                                       onclick="del(this)"
                                                       :data_id="item.id" :data_index="index">
                                                      删除
                                                    </a>

                                                    <!--<a class="layui-btn layui-btn-sm layui-btn-primary"-->
                                                       <!--onclick="hre(this)"-->
                                                       <!--:data_id="item.id" :data_index="index">-->
                                                        <!--内容管理-->
                                                    <!--</a>-->
                                                </div>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                                <div id="demo7"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    //vue对象
    var app = new Vue({
        el: '#app',
        data: {
            check: [],
            curr: 1,//当前页
            limit: 10,//当前页展示数目
            items: []
        }
    });

    //初始数据
    function init() {
        layer.load(2);
        $.get('/admin/sunfc.Passenger/index', '',
            function (res) {
                layer.closeAll();
                app.items = res.data;
            }
        );
    }

    //单独删除一条数据
    function del(that) {
        var id=$(that).attr('data_id');
        var index = layer.confirm('确认继续执行？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.post('{:url("del")}', {id: id}, function (res) {
                parent.layer.close(index);
                    if (res.code == 1) {
                         parent.layer.msg(res.msg, {icon: 1})
                         init();
                         return false;
                    }
                    else {
                         parent.layer.msg(res.msg, {icon: 2})
                         return false;
                    }
            });
        }, function () {
            parent.layer.close(index);
        });
    }

    //按需引入layui模块
    layui.use(['laypage', 'layer','table','element'], function () {
        var laypage = layui.laypage,
            layer = layui.layer;
        var table = layui.table;
        var elemnet = layui.element;
        //完整功能
        laypage.render({
            elem: 'demo7',//分页容器
            count: "{$count}",
            limits: [10, 20],
            layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
            jump: function (obj) {
                console.log(obj)
                app.curr = obj.curr;
                app.limit = obj.limit;
                init();
            }
        });

    });
    //Demo
    layui.use('form', function () {
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function (data) {
//            layer.msg(JSON.stringify(data.field));
            if (!data.field.keyword) {
                layer.confirm('你好，查询条件不允许为空！', {
                    btn: ['确定','取消'] //按钮
                }
                );
                return false;
            }
            layer.load(2);
            $.get('/admin/sunfc.Passenger/cases_search', data.field,
                function (res) {
                    layui.use(['laypage'], function () {
                        var laypage = layui.laypage;
                        //完整功能
                        laypage.render({
                            elem: 'demo7',
                            count: res.total ,
                            limits: [10, 20] ,
                            layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'] ,
                            jump: function (obj) {
                                console.log(obj)
                                app.curr = obj.curr;
                                app.limit = obj.limit;
                                layer.load(2);
                                $.get('/admin/sunfc.Passenger/cases_search', {
                                        page: app.curr,
                                        limit: app.limit,
                                        keyword: data.field.keyword
                                    },
                                    function (res) {
                                        layer.closeAll();
                                        app.items = res.data;
                                    }
                                );
                            }
                        });
                    });
                }
            );
            return false;
        });
    });

</script>


</body>
</html>




